# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=librsvg

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.40.2
pkgrel=1
pkgdesc="A SVG viewing library (mingw-w64)"
arch=(any)
url="https://live.gnome.org/LibRsvg"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
    "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
    "setconf")
depends=("${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2" "${MINGW_PACKAGE_PREFIX}-pango" "${MINGW_PACKAGE_PREFIX}-libcroco")
optdepends=("${MINGW_PACKAGE_PREFIX}-gtk3: for rsvg-view-3")
options=('staticlibs' 'strip')
source=("http://ftp.gnome.org/pub/gnome/sources/librsvg/${pkgver%.*}/${_realname}-$pkgver.tar.xz"
    "realpath.c"
    "rsvg-base.diff"
    give-cc-to-gir-scanner.mingw.patch)
sha256sums=('48049b643294636df7de1a4b997414d699666f5dc44776945c218a257d2a291c'
            'fbc045170a622463ff2094a0fcedcf0c9f8f3d47b01d633e6ebe71b004ded4ce'
            '1d96928913c3d3dca17f7d1340c3643c4a9f1466d2c3d6c9a444ee2ed12c906e'
            '854f36c9bc1ad0f3a85ca2ec4e8b5c7d75ba035c45ad4915601210acf0321776')

prepare() {
  cd "$srcdir/${_realname}-$pkgver"
  cp "$srcdir/realpath.c" .
  patch -Np0 -i "$srcdir/rsvg-base.diff"
  patch -p1 -i "$srcdir/give-cc-to-gir-scanner.mingw.patch"
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-$pkgver/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-introspection \
    --disable-tools
  setconf Makefile AM_CFLAGS '-fno-common'
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  #rm -r "${pkgdir}${MINGW_PREFIX}/share"
}
